package com.infonam.data.source.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
@Entity
@Table(name="payment", catalog="sakila")
public class Payment {
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="payment_id", unique=true,nullable=false)
	private int payment_id;
	@ManyToOne(fetch=FetchType.LAZY)
	@Cascade({CascadeType.ALL})
	@JoinColumn(name="customer_id",nullable=false)
	private Customer customer;
	@ManyToOne(fetch=FetchType.LAZY)
	@Cascade({CascadeType.ALL})
	@JoinColumn(name="staff_id",nullable=false)
	private Staff taff;
	@ManyToOne(fetch=FetchType.LAZY)
	@Cascade({CascadeType.SAVE_UPDATE})
	@JoinColumn(name="rental_id",nullable=false)
	private Rental rental;
	@Column(name="amount", nullable=false)
	private float amount;
	@Temporal(TemporalType.DATE)
	@Column(name="payment_date", nullable=false)
	private Date payment_date;
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="last_update", nullable=false, columnDefinition="TIMESTAMP default CURRENT_TIMESTAMP on update TIMESTAMP")
	private Date last_update;
	public Payment() {
		super();
	}
	public int getPayment_id() {
		return payment_id;
	}
	public void setPayment_id(int payment_id) {
		this.payment_id = payment_id;
	}
	public Customer getCustomer() {
		return customer;
	}
	public void setCustomer(Customer customer) {
		this.customer = customer;
	}
	public Staff getTaff() {
		return taff;
	}
	public void setTaff(Staff taff) {
		this.taff = taff;
	}
	public Rental getRental() {
		return rental;
	}
	public void setRental(Rental rental) {
		this.rental = rental;
	}
	public float getAmount() {
		return amount;
	}
	public void setAmount(float amount) {
		this.amount = amount;
	}
	public Date getPayment_date() {
		return payment_date;
	}
	public void setPayment_date(Date payment_date) {
		this.payment_date = payment_date;
	}
	public Date getLast_update() {
		return last_update;
	}
	public void setLast_update(Date last_update) {
		this.last_update = last_update;
	}
}
